global class CMRGroupIdHandler
{  
    public static Integer getMaxCMRId()
    {
        Integer currmax = 0;
        Integer tmp = 0;
        ID CMRGroupRecordTypeID = RecordTypeHelper.GetRecordTypeID('Account', 'CMR Group');
        List<account> acs = [select id, CMR_Group_ID__c, RecordType.Name from account where RecordTypeId =:CMRGroupRecordTypeID];
        for (account a : acs)
        {
            tmp = integer.valueof(a.CMR_Group_ID__c);
            if (tmp > currmax)
                currmax = tmp;
        }
        return currmax;
    }
}